package com.my.okhttps.test;

import cn.hutool.core.date.DateUtil;
import com.my.core.api.R;
import com.my.okhttps.test.service.ISheBao2Service;
import com.my.okhttps.test.vo.shebao2.InputXml;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 省卡系统查询社保
 * @author timo 2020/12/24
 */
@RestController
@RequestMapping("/shebao2/shebaoquery")
@Slf4j
public class SheBao2Controller {

    @Autowired
    private ISheBao2Service iSheBao2Service;
    /**
     * 社会保障卡信息查询
     * @param idCard
     * @return
     */
    @GetMapping(value = "/getCardInfo")
    public R<?> getCardInfo(@RequestParam String idCard){
        InputXml inputXml = new InputXml(idCard);
        return R.data(iSheBao2Service.getCardInfo(inputXml));
    }

    /**
     * 就业外出务工地查询
     * @param idCard
     * @return
     */
    @GetMapping(value = "/goOutWorkPlaceQuery")
    public R<?> goOutWorkPlaceQuery(@RequestParam String idCard){
        InputXml inputXml = new InputXml();
        inputXml.setWorkIdCard(idCard);
        return R.data(iSheBao2Service.goOutWorkPlaceQuery(inputXml));
    }

    /**
     * 惠民惠农一卡通支付明细
     * @param idCard
     * @return
     */
    @GetMapping(value = "/ecardQuery")
    public R<?> ecardQuery(@RequestParam String idCard,
                           @RequestParam String year){
        InputXml inputXml = new InputXml(idCard);
        inputXml.setYear(StringUtils.isNotBlank(year)?year:DateUtil.year(DateUtil.date())+"");
        return R.data(iSheBao2Service.ecardQuery(inputXml));
    }

//    /**
//     * 社会保障卡激活
//     * @return
//     */
//    @PostMapping(value = "/activate")
//    public Result<?> activate(@RequestParam String idCard){
////        @Validated @RequestBody SheBao2ActivateVo activateVo
////        InputXml inputXml = BeanUtil.copyProperties(activateVo, InputXml.class);
//        InputXml inputXml = new InputXml(idCard);
//        return Result.OK(iSheBao2Service.activate(inputXml));
//    }
//
//    /**
//     * 社保卡挂失、解挂、冻结
//     * @param idCard
//     * @param ywlx
//     * @return
//     */
//    @PostMapping(value = "/otherOperation")
//    public Result<?> otherOperation(@RequestParam String idCard, @RequestParam String ywlx){
//        InputXml inputXml = new InputXml(idCard);
//        inputXml.setServiceType(ywlx);
//        return Result.OK(iSheBao2Service.otherOperation(inputXml));
//    }
//
//    /**
//     * ZY1000 社会保障卡参保关系转移
//     * @param idCard
//     * @return
//     */
//    @PostMapping(value = "/relationTransfer")
//    public Result<?> relationTransfer(@RequestParam String idCard){
//        InputXml inputXml = new InputXml(idCard);
//        return Result.OK(iSheBao2Service.relationTransfer(inputXml));
//    }
}
